#ifndef __SHSTYLE_H
#define __SHSTYLE_H
#include "matrix.h"
#include "mxsetup.h"

/**
 * HEAD basic format:
 *      [logo][info][div]xxx
 * sample:
 *      matrix ●    >   xxx
 *      `````` ``   ``  ```
 *      logo  info div  content
 */

#define MX_SHSTYLE_HEAD(logo, info, div) (#logo#info#div)
#define MX_SHSTYLE_LOGG MXSETUP_SHSTYLE_LOGO

/* the output style of shell */
typedef enum
{
    /* terminal basic */
    MX_SHSTYLE_MODE_NONE,
    MX_SHSTYLE_MODE_LOGO,
    MX_SHSTYLE_MODE_INFO,
    MX_SHSTYLE_MODE_DIV,
    MX_SHSTYLE_MODE_CONTENT,
    /* output style */
    MX_SHSTYLE_MODE_WARN,
    MX_SHSTYLE_MODE_ERROR
} mx_shstyle_mode;

/* the descriptor of shell style */
typedef struct
{
    /* the HEAD information */
    struct
    {
        mx_size_t length;       // length = strlen(logo + info + div), -1 means not calculated
        mx_string_pt logo;
        mx_string_pt info;
        mx_string_pt div;
    } head;
    /* the style information */
    struct
    {
        mx_string_pt current;   // record current style, null at startup
        mx_string_pt logo;
        mx_string_pt info;
        mx_string_pt div;
        mx_string_pt content;
        mx_string_pt warn;
        mx_string_pt error;
    } style;
} mx_shstyle_t, *mx_shstyle_pt;

/**
 * draw the shell head, like: matrix ●>
 * @param: void
 * @note: this function should change the style.current if need
 * @return: void
 */
void mx_shstyle_drawhead (void);
/**
 * change the shell style
 * @param mode: the style mode
 * @note: the style will be changed only if the mode is different from the current style
 * @return: void
 */
void mx_shstyle_change (mx_shstyle_mode mode);
/**
 * get the shell head length
 * @param: void
 * @return: strlen(logo + info + div)
 */
mx_size_t mx_shstyle_headlength (void);
/**
 * get the current style
 * @param: void
 * @return: the current style
 */
mx_string_pt mx_shstyle_currentstyle (void);

#endif
